from pydantic import BaseModel
from datetime import datetime
from typing import Optional

class FileVersionBase(BaseModel):
    comment: Optional[str] = ""

class FileVersionCreate(FileVersionBase):
    pass

class FileVersionInfo(FileVersionBase):
    id: int
    file_id: int
    version_number: int
    size: int
    mime_type: Optional[str]
    checksum: Optional[str]
    created_by: int
    creator_name: Optional[str] = None
    is_current: bool
    created_at: datetime
    
    class Config:
        from_attributes = True

class FileVersionList(BaseModel):
    versions: list[FileVersionInfo]
    total: int
    current_version: Optional[int] = None
    
class VersionCompare(BaseModel):
    version1: FileVersionInfo
    version2: FileVersionInfo
    size_diff: int
    time_diff: str